/*==============================================
            Project Created By Felix
                    2025.09
==============================================*/

#include "ti_msp_dl_config.h"
#include "FreeRTOS.h"
#include "task.h"

void task_Blink(void*);
TaskHandle_t task_Blink_Handle = {0};

void task_TX(void*);
TaskHandle_t task_TX_Handle = {0};

int main(void)
{
    SYSCFG_DL_init();
    
    BaseType_t xReturn = pdPASS;

    xReturn = xTaskCreate(task_Blink, "Blink", 128, NULL, 2, &task_Blink_Handle);
    if (xReturn != pdPASS) while(1);

    xReturn = xTaskCreate(task_TX, "UART_TX", 384, NULL, 1, &task_TX_Handle);
    if (xReturn != pdPASS) while(1);

    DL_GPIO_setPins(LED_PORT, LED_LEDR_PIN | LED_LEDY_PIN);
    vTaskStartScheduler();

    return 0;
}


/* ==================== DEFINITIONS ==================== */

void task_Blink(void* p)
{
    (void)p;
    while(1)
    {
        DL_GPIO_togglePins(LED_PORT, LED_LEDY_PIN);
        vTaskDelay(500);
    }
}

void task_TX(void* p)
{
    (void)p;
    char msg[8] = "task_TX\n";
    while(1)
    {
        for(uint8_t i=0;i<8;i++)
        {
            DL_UART_transmitDataBlocking(UART0,msg[i]);
        }
        vTaskDelay(2000);
    }
}